<template>
  <view :style="themeColor">
    <view class="page">
      <view
        class="flex flex-direction flex-wrap align-stretch justify-center benben-position-layout flex bindnewEmail_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-stretch justify-between bindnewEmail_fd0_0'>
          <view class='flex flex-wrap align-center bindnewEmail_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  bindnewEmail_fd0_0_c0_c0'>&#xe794;</text>
          </view>
          <view class='flex flex-wrap align-center'>
            <text class='bindnewEmail_fd0_0_c1_c0'>绑定新邮箱</text>
          </view>
          <view class='flex align-center justify-end bindnewEmail_fd0_0_c2'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---修改密码-手机验证-表单flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch bindnewEmail_flex_1">
        <view class='flex flex-wrap align-center bindnewEmail_fd1_0'>
          <text class='bindnewEmail_fd1_0_c0'>新邮箱号码</text>
          <benben-input class='flex-sub bindnewEmail_fd1_0_c1' type="text" :focus='true' :placeholder="`请输入新的邮箱号`"
            confirm-type="done" :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
            v-model="email" />
        </view>
        <view class='flex flex-wrap align-center bindnewEmail_fd1_0'>
          <text class='bindnewEmail_fd1_0_c0'>邮箱验证</text>
          <benben-input class='flex-sub bindnewEmail_fd1_0_c1' type="number" :focus='false' :placeholder="`请输入验证码`"
            confirm-type="done" :maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
            v-model="code" />
          <benben-send-verification-code key='1704938103706' ref="vCode1704938103706" class=' bindnewEmail_fd1_1_c2'
            after-text='后重新获取' before-text='获取验证码' emptye-text='请输入邮箱号' validate-text='请输入正确邮箱号' account-type='email'
            :auto='true' type='3' :phone="email"></benben-send-verification-code>
        </view>
        <button class='bindnewEmail_fd1_2' @tap.stop="checkPwdFunc()">完成</button>
      </view>

      <!---修改密码-手机验证-表单flex布局结束-->


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},


    data() {
      return {
        "code": "",
        "email": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //校验密码
      async checkPwdFunc() {
        if (!validate(this.email, 'require')) {
          this.$message.info('邮箱号不能为空');
          return false;
        }
        if (!validate(this.email, 'emailzh')) {
          this.$message.info('请输入正确的邮箱号');
          return false;
        }
        if (!validate(this.code, 'require')) {
          this.$message.info('验证码不能为空');
          return false;
        }
        if (!validate(this.code, 'captcha')) {
          this.$message.info('请输入正确的验证码');
          return false;
        }
        //请求方法
        //数据验证

        let data5caeeba9866aa = await this.$api.post(global.apiUrls.post65767b25c12c2, {
          email: this.email,
          code: this.code,
          account_type: 'email',
          type: '3'
        });

        if (data5caeeba9866aa.data.code != 1) {
          this.$message.info(data5caeeba9866aa.data.msg);
          return
        }



        this.$store.commit('logout')
        setTimeout(() => {
          this.$urouter.reLaunch(`/pages/tabBar/passwordLogin/passwordLogin`);
        }, 500)
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .bindnewEmail_flex_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .bindnewEmail_fd0_0_c2 {
    padding: 0rpx 0rpx 0rpx 0rpx;
    width: 100rpx;
  }

  .bindnewEmail_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: var(--benbenFontColor0);
    line-height: 50rpx;
  }

  .bindnewEmail_fd0_0_c0_c0 {
    font-size: 36rpx;
    font-weight: 400;
    color: #333;
  }

  .bindnewEmail_fd0_0_c0 {
    width: 100rpx;
  }

  .bindnewEmail_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
  }

  .bindnewEmail_flex_1 {
    background: #fff;
    font-size: 32rpx;
    background-size: 100% auto !important;
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .bindnewEmail_fd1_2 {
    background: rgba(100, 80, 235, 1);
    border-radius: 44rpx 44rpx 44rpx 44rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor3);
    width: 638rpx;
    height: 88rpx;
    line-height: 88rpx;
    font-weight: 500;
    margin: 297rpx 0rpx 0rpx 24rpx;
  }

  .bindnewEmail_fd1_1_c2 {
    line-height: 42rpx;
    text-align: center;
    font-size: 28rpx;
    color: rgba(100, 80, 235, 1);
  }

  .bindnewEmail_fd1_0_c1 {
    line-height: 45rpx;
    font-size: 32rpx;
    font-weight: 400;
    color: var(--benbenFontColor0);
  }

  .bindnewEmail_fd1_0_c0 {
    font-size: 32rpx;
    font-weight: 400;
    font-style: normal;
    color: rgba(127, 127, 127, 1);
    width: 182rpx;
  }

  .bindnewEmail_fd1_0 {
    border-bottom: 1px solid #eee;
    padding: 32rpx 0rpx 32rpx 0rpx;
  }
</style>
